﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project
{
    public partial class FJtian : Form
    {
        public FJtian()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            fjtian();
        }
        public void fjtian() 
        {
            string name = this.textBox1.Text;
           int leixing = Convert.ToInt32(this.comboBox1.SelectedValue);
            if(string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请填写完整");
            }
            string sql = string.Format("insert into RoomInfo values('{0}',{1},{2},{3},{4})", name, leixing, 200, leixing,1);

            int result = FrmHotel.DBHelper.ExecuteUpdate(sql);
            if (result > 0)
            {
                MessageBox.Show("添加成功");
                this.Close();
            }
            else 
            {
                MessageBox.Show("添加失败");
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void FJtian_Load(object sender, EventArgs e)
        {
            string sql = "select * from Room";
            DataTable dt =FrmHotel.DBHelper.SelectForTable(sql);
            this.comboBox1.DisplayMember = "RoomName";
            this.comboBox1.ValueMember = "RoomId";
            this.comboBox1.DataSource = dt;
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
